namespace CloudNinja.Metering.Providers
{
    using System;
    using System.Globalization;
    using System.Web;

    using Microsoft.WindowsAzure.Storage.Table;

    public class ParserBookmark : TableEntity
    {
        private string logName;

        public ParserBookmark(string logSet, string logName, DateTime lastTimeParsed, int lastLineParsed)
            : base(logSet, lastTimeParsed.ToString("o", CultureInfo.InvariantCulture))
        {
            this.LogName = logName;
            this.LastLineParsed = lastLineParsed;
            this.LastTimeParsed = lastTimeParsed;
        }

        public ParserBookmark()
        {
        }

        public string LogSet
        {
            get
            {
                return this.PartitionKey;
            }

            set
            {
                this.PartitionKey = value;
            }
        }

        public string LogName
        {
            get
            {
                return HttpUtility.UrlDecode(this.logName);
            }

            set
            {
                this.logName = HttpUtility.UrlEncode(value);
            }
        }

        public DateTime LastTimeParsed { get; set; }

        public int LastLineParsed { get; set; }
    }
}